<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="UTF-8" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0" />
		<title>Document</title>
		<script src="./lib/echarts.min.js"></script>
		<script src="./lib/jquery.min.js"></script>
	</head>
	<body>
		<div
			id="bar"
			style="width: 600px; height: 400px; border: 1px solid red"
		></div>
		<div
			id="map"
			style="width: 600px; height: 400px; border: 1px solid blue"
		></div>

		<script type="text/javascript">
			let mCharts = echarts.init(document.querySelector('#bar'), 'dark');

			let xData = ['张三', '李四', '王五', '闰土', '小明', '三看', '大强'];
			let yData = [84, 43, 68, 79, 90, 98, 57];
			let option = {
				toolbox: {
					feature: {
						saveAsImage: {},
					},
				},
				//图标的 x 轴
				xAxis: {
					type: 'category',
					data: xData,
				},
				yAxis: {
					type: 'value',
				},
				//系列列表
				series: [
					{
						name: '语文',
						type: 'bar',
						markPoint: {
							data: [
								{
									type: 'max',
									name: '最大值',
								},
								{
									type: 'min',
									name: '最小值',
								},
							],
						},
						markLine: {
							data: [
								{
									type: 'average',
									name: '平均值',
								},
							],
						},
						label: {
							show: true,
							rotate: 15,
						},
						barWidth: '50%',
						data: yData,
					},
				],
			};

			mCharts.setOption(option);

			let mCharts2 = echarts.init(document.querySelector('#map'), 'light');
			$.get('./json/map/china.json', function (ret) {
				echarts.registerMap('china', ret);
				let option2 = {
					geo: [
						{
							type: 'map',
							map: 'china',
						},
					],
				};
				mCharts2.setOption(option2);
			});
			echarts.connect([mCharts, mCharts2]); //将两个图表关联起来
		</script>
	</body>
</html>
